public class Demo1 {
    private static Object locker = new Object();

    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
            synchronized (locker){
                System.out.println("wait 之前");
                try {
                    locker.wait();
                } catch (InterruptedException e) {
                    //由于会抛出异常，所以日志需要加在这，
                    //加到下面的话就看不到了，因为可能就跳过了
                    System.out.println("wait 之后");
                    throw new RuntimeException(e);
                }
            }
        });
        t.start();

        Thread.sleep(1000);

        t.interrupt();
    }
}
